layui.use(['table', 'jquery', 'layer'], function(){
    var $ = layui.$
    var table = layui.table
    var layer = layui.layer

    $('#submit').click(function () {
        if ($('#code').val().trim() != '') document.location.href = '/file.aspx?code=' + $('#code').val().trim()
        else layer.msg('提取码不能为空')
    })


    table.on('tool', function(obj){
        let data = obj.data
        let code = document.location.href.match(/code=(.{16})/)[1]
        if(obj.event === 'check'){
            if(data.type == 0) document.location.href = '/file.aspx?code=' + code + '&path=' + data.id
        }else if(obj.event === 'down'){
            if(data.type != 0){
                layer.msg('正在准备下载')
                window.open('/download.aspx?file='+data.code);
            }else{
                layer.msg('文件夹不支持直接下载')
            }
        }
    })
})